package J20250330_real;

/**
 * Created with IntelliJ IDEA.
 * Description: 迷宫
 * User: 王圆豪
 * Date: 2025-04-01
 * Time: 20:48
 */
import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main2 {
    static char[] arr;
    static int n;
    static boolean flag;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        scan.nextLine();
        String s = scan.next();
        arr = s.toCharArray();
        char[][] table = new char[n+1][n+1];
        for(char[] tmp : table){
            Arrays.fill(tmp, '*');
        }
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                dfs(i,j,table,0);
                if(flag) break;
            }
            if(flag) break;
        }
        for(int i = 0; i <= n; i++){
            boolean ju = false;
            for(int j = 0; j <= n; j++){
                if(table[i][j] == '*'&&((i+1<=n&&table[i+1][j]==' ')||(i-1>=0&&table[i-1][j]==' ')||
                        (j+1<=n&&table[i][j+1]==' ')||(j-1>=0&&table[i][j-1]==' '))){
                    System.out.print("*");
                    ju = true;
                } else
                    System.out.print(" ");
            }
            if(ju)
                System.out.println();
            else break;
        }
        scan.close();
    }

    static void dfs(int x, int y, char[][] table, int pos){
        if(x <= 0 || y <= 0) return;
        if(pos == arr.length){
            flag = true;
            return;
        }
        table[x][y] = ' ';
        if(arr[pos] == 'U') dfs(x-1,y,table,pos+1);
        else if(arr[pos] == 'D') dfs(x+1,y,table,pos+1);
        else if(arr[pos] == 'L') dfs(x,y-1,table,pos+1);
        else if(arr[pos] == 'R') dfs(x,y+1,table,pos+1);
        if(flag) return;
        table[x][y] = '*';
    }
}